package com.yksj.healthtalk.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yksj.healthtalk.ui.R;

/**
 * 
 * 评论适配器
 * @author zhao
 *
 */
public class CommentAdapter extends BaseAdapter {
	final LayoutInflater mInflater;
	final List<Map<String,String>> mList = new ArrayList<Map<String,String>>();
	
	public CommentAdapter(LayoutInflater inflater) {
		mInflater = inflater;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	@Override
	public int getItemViewType(int position) {
		if(position == 0)return 1;
		return 2;
	}
	
	@Override
	public int getViewTypeCount() {
		return 3;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final int type = getItemViewType(position);
		CommenViewHolder holder;
		if(convertView == null){
			if(type == 1){
				convertView = mInflater.inflate(R.layout.news_comment_size_list_item,null);
				holder = new CommenViewHolder();
				convertView.setTag(holder);
			}else{
				convertView = mInflater.inflate(R.layout.news_comment_list_item,null);
				holder = new CommenViewHolder();
				convertView.setTag(holder);
				
				holder.headerImageView = (ImageView)convertView.findViewById(R.id.head_image);
				holder.nameTextView = (TextView)convertView.findViewById(R.id.nameTxt);
				holder.timeTextView = (TextView)convertView.findViewById(R.id.timeTxt);
				holder.contentTextView = (TextView)convertView.findViewById(R.id.contentTxt);
				holder.repeatImageView = (ImageView)convertView.findViewById(R.id.comment_repeat);
			}
		}else{
			holder = (CommenViewHolder)convertView.getTag();
		}
		return convertView;
	}
	
	static class CommenViewHolder{
		TextView nameTextView;
		TextView timeTextView;
		TextView contentTextView;
		ImageView headerImageView;
		ImageView repeatImageView;
	}
}
